package com.wc.alorithm_luogu.P6044_Prawnicy;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/3/7 22:30
 * @description https://www.luogu.com.cn/problem/solution/P6044
 */
public class Answer {
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 1000010;
    static int[][] a = new int[N][3];
    static int n, k, l, r;

    // 正确的思路是,答案一定是一个线段的左端点和另一个线段的右端点
    public static void main(String[] args) {
        n = sc.nextInt();
        k = sc.nextInt();
        for (int i = 1; i <= n; i++) {
            a[i][0] = i;
            a[i][1] = sc.nextInt();
            a[i][2] = sc.nextInt();
        }
        Arrays.sort(a, 1, n + 1, ((o1, o2) -> {
            if (o1[1] == o2[1]) {
                return o1[2] - o2[2];
            }
            return o1[1] - o2[1];
        }));
        PriorityQueue<Integer> q = new PriorityQueue<>();
        int maxTime = 1;
        for (int i = 1; i <= n; i++) {
            q.add(a[i][2]);
            while (q.size() > k) {
                q.poll();
            }
            // 当某一个右端点恰好有k个数组,右端点最左边的数一定满足k个,所以就代表了某一个端点的左端点
            if (q.size() == k) {
                if (q.peek() - a[i][1] > maxTime) {
                    l = a[i][1];
                    r = q.peek();
                    maxTime = r - l;
                }
            }
        }

        out.println(maxTime);
        for (int i = 1; i <= n; i++) {
            if (a[i][1] <= l && a[i][2] >= r && k > 0) {
                out.print(a[i][0] + " ");
                k--;
            }
        }
        out.flush();
    }

    static class FastReader {
        StringTokenizer st;
        BufferedReader br;

        FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        String nextLine() {
            String s = "";
            try {
                s = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return s;
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        // 是否由下一个
        boolean hasNext() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String line = br.readLine();
                    if (line == null)
                        return false;
                    st = new StringTokenizer(line);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return true;
        }
    }
}
